package cn.itcast.bos.delivery.action;

import org.apache.commons.lang.StringUtils;
import org.apache.struts2.ServletActionContext;
import org.apache.struts2.convention.annotation.Action;
import org.apache.struts2.convention.annotation.Namespace;
import org.apache.struts2.convention.annotation.ParentPackage;
import org.apache.struts2.convention.annotation.Result;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Controller;

import cn.itcast.bos.base.action.BaseAction;
import cn.itcast.bos.delivery.service.OrderService;
import cn.itcast.bos.domain.delivery.Order;


@Namespace("/")
@ParentPackage("json-default")
@Controller
@Scope("prototype")
public class OrderAction extends BaseAction<Order>{
	@Autowired
	private OrderService orderService;
	private Logger logger = LoggerFactory.getLogger(getClass());
	@Action(value="getOrderByNum",results={@Result(name="success",type="json",params={"excludeNullProperties","true"})})
	public String getOrderByNum(){
		if(StringUtils.isNotBlank(t.getOrderNum())){
			logger.info(t.getOrderNum());
			Order order=orderService.findByOrderNum(t.getOrderNum());
			ServletActionContext.getContext().getValueStack().push(order);
		}
		return SUCCESS;
	}
}
